class Solution:
    def numKLenSubstrNoRepeats(self, s: str, k: int) -> int:
        count = [0] * 26

        if len(s) < k:
            return 0

        for i in range(k):
            a = ord(s[i]) - 97
            count[a] += 1

        ans = 1 if max(count) <= 1 else 0

        for i in range(k, len(s)):
            a1 = ord(s[i]) - 97
            count[a1] += 1
            a2 = ord(s[i - k]) - 97
            count[a2] -= 1
            if max(count) <= 1:
                ans += 1

        return ans


if __name__ == "__main__":
    print(Solution().numKLenSubstrNoRepeats(s="havefunonleetcode", k=5))  # 6
    print(Solution().numKLenSubstrNoRepeats(s="home", k=5))  # 0
